import { _decorator, Component, Node } from 'cc';
import { NodePool } from '../../../../sgame/pool/NodePool';
import { UIWait } from './UIWait';
const { ccclass, property } = _decorator;

@ccclass('UIWaitLayer')
export class UIWaitLayer extends Component {
    @property(NodePool)
    public pool: NodePool;

    public show(text?: string): Function {
        let waitNode = this.pool.get();
        waitNode.getComponent(UIWait).show(text);
        return () => {
            this.hide(waitNode);
        };
    }

    public hide(waitNode: Node) {
        this.pool.put(waitNode);
    }
}